package com.gemantic.task.dao.local;


import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import com.gemantic.task.dto.ActiveTaskQueryParam;
import com.gemantic.task.dto.TaskQueryReqDto;
import com.gemantic.task.model.Task;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.json.JSONUtil;

/**
 * @author xiedi
 * @date 2022/09/15
 **/
@Repository
public interface TaskDao {

    void closeTask(@Param("orderNo") String orderNo, @Param("taskType") String taskType, @Param("remark") String remark);

    Task selectByPrimaryKey(@Param("id") long id);

    Task lockByPrimaryKey(@Param("id") long id);

    int updateByPrimaryKey(Task item);

    int insertSelective(Task item);

    List<Task> getOpenTaskByOrder(@Param("orderNo") String orderNo, @Param("type") String type);

    List<Task> getActiveTasks(ActiveTaskQueryParam param);

    List<Task> getOpenTask();

    int pendTask(@Param("id") long id, @Param("originStatus") String originStatus, @Param("originVersion") Integer originVersion);

    int batchUpdate(@Param("nextRunTime") Date nextRunTime, @Param("status") String status, @Param("list") List<Long> tasks);

    List<List<Task>> getTasks(TaskQueryReqDto reqDto);

    int modifyTaskFromUI(Task task);

    public static void main(String[] args) {
        List<String> list = ListUtil.of("closeTask","pendTask","getTasks","selectByPrimaryKey","lockByPrimaryKey","updateByPrimaryKey","insertSelective","getOpenTaskByOrder","getActiveTasks","getOpenTask","batchUpdate","modifyTaskFromUI");
         for (Method  declaredMethod : TaskDao.class.getDeclaredMethods()) {
            System.out.println(declaredMethod.getName());
            list.add(declaredMethod.getName());
        }
        System.out.println(JSONUtil.toJsonStr(list));
    }

    List<Task> getAllTaskByOrder(@Param("orderNo") String orderNo, @Param("type") String type);
}
